/**
 * JSparrow - Une version numérique du jeu "Attention Pirates !" - Copyright (C) 2014 Black Pearl
 *
 * This program is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program. If
 * not, see <http://www.gnu.org/licenses/>.
 */
package App.Vue;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JPanel;

import App.Controleur.Jeu;

public class Panneau_Option extends JDialog{



	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final Jeu controleur;
	private static Panneau_Option options;

	public Panneau_Option(JPanel panel, Jeu controleur){
		super();  
		options = this;
		this.controleur = controleur;
		initComponents();  
		pack();  
		setLocationRelativeTo(panel);
		setVisible(true);
	}


	private void initComponents(){
		//Creation des boutons
		JButton reprendre = new JButton("Reprendre");
		JButton regles = new JButton("Règles");
		JButton sauvegarder = new JButton("Sauvegarder");
		
		reprendre.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				options.dispose();
			}
		});
		
		sauvegarder.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				controleur.sauvegarderPartie();
				options.dispose();
			}
		});
		
		
		//Layout
		this.setLayout(new GridBagLayout());
		
		//Ajout des boutons au panel
		addItem(reprendre	, 0, 0);
		addItem(regles		, 0, 1);
		addItem(sauvegarder	, 0, 2);
	}
	
	/**
	 * Ajoute un composant à la gridBagLayout
	 * @param c Element à ajouter
	 * @param x colonne de la grille
	 * @param y ligne de la grille
	 */
	private void addItem(JComponent c, int x, int y) {
		GridBagConstraints gc = new GridBagConstraints();
		gc.gridx = x;
		gc.gridy = y;
		gc.gridwidth = 1;
		gc.gridheight = 1;
		gc.weightx = 1;
		gc.weighty = 1;
		gc.insets = new Insets(2,2,2,2);
		gc.anchor = GridBagConstraints.CENTER;
		gc.fill = GridBagConstraints.BOTH;
		this.add(c, gc);
	}
	
	public void Ok_Clic(){

	}

	public void Non_Clic(){

	}

	public void Annuler_Clic(){

	}
}
